package com.xlh.dto.courseTest.paper;

import com.xlh.dto.courseTest.ReportDTO;
import com.xlh.enums.courseTest.QuestionTypeEnum;
import com.xlh.pojo.courseTest.CourseTestPaperAnswerSheet;
import com.xlh.pojo.courseTest.CourseTestPaperQuestion;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author zhr 2019/4/18
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ExperimentPaperDTO extends StudentPaperDTO {
    // 实验报告下载路径
    private String filePath;
    // 实验报告模板下载路径
    private String modelPath;
    // 题目题干
    private String content;
    // 实验报告
    private String report;
    // 实验题对应题库id
    private Long originQuestionId;
    // 实验报告文件实际名称
    private String fileName;

    public ExperimentPaperDTO transform(ReportDTO report, Long timeLeft, CourseTestPaperAnswerSheet answerSheet, CourseTestPaperQuestion question) {
        if (report.getFilePath() != null) {
            this.setFilePath(report.getFilePath());
            this.setFileName(report.getReportFileName());
        }
        this.setModelPath(report.getModelPath());
        this.setReport(report.getReportMd());
        this.setTimeLeft(timeLeft);
        this.setId(question.getId());
        this.setOrderNumber(question.getOrderNumber());
        this.setType(question.getType());
        this.setScore(question.getScore());
        this.setContent(question.getHtmlContent());
        this.setTypeName(QuestionTypeEnum.forCode(this.getType()).getMessage());
        this.setAnswerSheetId(answerSheet.getId());
        this.setOriginQuestionId(question.getOriginQuestionId());
        return this;
    }
}
